package view.popup 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import model.GameData;
	import view.Base;
	
	/**
	 * ...
	 * @author @Boy_Kute
	 */
	public class Tooltip extends Base 
	{
		
		private var _tooltipAll:MovieClip;
		private var _imgAnimal:MovieClip;
		private var _arrImg:Array = [];
		public function Tooltip() 
		{
			_tooltipAll = getImage("tipAll", "playGame");
			addChild(_tooltipAll);
			GameData.getInstance().addEventListener("showTip", showTip);
		}
		
		private function showTip(e:Event):void 
		{
			//var i:int
			//if (_arrImg && _arrImg.length > 0)
			//{
				//for (i = 0; i < _arrImg.length; i++) 
				//{
					//removeChild(_arrImg[i]);
					//_arrImg[i] = null;
				//}
			//}
			//_arrImg = [];
			
			if (_imgAnimal)
			{
				removeChild(_imgAnimal);
				_imgAnimal = null;
			}
			if (!_imgAnimal)
			{
				_imgAnimal = getImage(GameData.getInstance().arrTip[1], "playGame")
				addChild(_imgAnimal);
				_imgAnimal.width = 46.85;
				_imgAnimal.height = 33;
				_tooltipAll.txttip.text = String(GameData.getInstance().arrTip[0]) + ",tỷ lệ ăn x " + String(GameData.getInstance().arrTip[2]);
				trace(_tooltipAll.txttip.text)
				
				_arrImg.push(_imgAnimal);
				trace();
			}
		}
		
		public function showTextTime(str:String):void
		{
			var i:int
			if (_arrImg && _arrImg.length > 0)
			{
				for (i = 0; i < _arrImg.length; i++) 
				{
					_arrImg[i].visible = false;
				}
			}
			_tooltipAll.txttip.text = str;
		}
		
		//public function showTextQTT(str:String):void
		//{
			//var i:int;
			//if (_arrImg && _arrImg.length > 0)
			//{
				//for (i = 0; i < _arrImg.length; i++) 
				//{
					//_arrImg[i].visible = false;
				//}
			//}
			//_tooltipAll.txttip.text = str;
		//}
	}

}